import React from 'react';
import { observer, inject } from 'mobx-react';

@inject('wfLayoutStore')
@observer
export default class SystemField extends React.Component{
    constructor(){
        super();
    }
    shouldComponentUpdate(){
        return false;
    }
    render(){
        const { cellObj,wfLayoutStore } = this.props;
        const { etype } = cellObj;
        const fieldid = cellObj.field.toString();
        const { cellInfo } = wfLayoutStore;
        const { workflowname="",workflowtypename="",workflowdesc="" } = cellInfo.sysFieldInfo || {};
        let text = "";
        if(etype == "28"){
            text = cellObj.evalue;
        }else if(etype == "29"){
            if(fieldid == "1")
                text = workflowname;
            else if(fieldid == "2")
                text = workflowtypename;
            else if(fieldid == "3")
                text = workflowdesc;
        }
        text = text.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/(\r\n|\r|\n)/g, "</br>");
        text = text.replace(/ /g,"&nbsp;");

        return (
            <span dangerouslySetInnerHTML={{__html: `${text}`}}></span>
        )
    }
}